package pe.com.bn.sach.dao.impl;

import java.util.List;
import com.ibatis.sqlmap.client.SqlMapClient;


import pe.com.bn.sach.domain.Bnchf53CalPrestOtroBanc;
import pe.com.bn.sach.dao.CalPresOtrosBancDAO;

import org.apache.log4j.Logger;

public class CalPresOtrosBancImpl  implements CalPresOtrosBancDAO
{

	private static Logger depurador = Logger.getLogger(CalPresOtrosBancImpl.class.getName());
	protected SqlMapClient sqlMap = null;
	
	public void setSqlMap(SqlMapClient sqlMap) {
		this.sqlMap = sqlMap;
	}
	

	public int GuardaCalcPresOtrosBanc(Bnchf53CalPrestOtroBanc bnchf53CalPrestOtroBanc) 
				throws Exception{	
				int r =0;
    		try{
    			sqlMap.startTransaction();
    			sqlMap.insert("sqlCalPresOtrosBanc.GuardaCalcPresOtrosBanc",bnchf53CalPrestOtroBanc);
    			sqlMap.commitTransaction();
    			
    			r=1;
    		} catch (Exception e) {
				e.printStackTrace();
				throw e;
			 } finally {
			    sqlMap.endTransaction();
			}
    	 return r;
    }
	
	public void ActualizaCalcPresOtrosBanc(Bnchf53CalPrestOtroBanc bnchf53CalPrestOtroBanc) 
	throws Exception{	 
		    try {
        	sqlMap.startTransaction();
        	sqlMap.update("sqlCalPresOtrosBanc.ActualizacalPresOtrosBanc",bnchf53CalPrestOtroBanc);
        	sqlMap.commitTransaction();
        	
        } catch (Exception e) {
			e.printStackTrace();
			throw e;
		 } finally {
		    sqlMap.endTransaction();
		}
    }
	
	public void ActualizaCalcPresOtrosBancStado(Bnchf53CalPrestOtroBanc bnchf53CalPrestOtroBanc) 
	throws Exception{	    
	
		try {
			sqlMap.startTransaction();
			sqlMap.update("sqlCalPresOtrosBanc.ActualizacalPresOtrosBancStado",bnchf53CalPrestOtroBanc);
			sqlMap.commitTransaction();
			
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		 } finally {
		    sqlMap.endTransaction();
		}
}
	
	public void DeleteCalcPresOtrosBanc(Bnchf53CalPrestOtroBanc bnchf53CalPrestOtroBanc) 
	throws Exception{	   
					try {
					sqlMap.startTransaction();
					sqlMap.delete("sqlCalPresOtrosBanc.deletecalPresOtrosBanc",bnchf53CalPrestOtroBanc);
					sqlMap.commitTransaction();
				
				} catch (Exception e) {
					e.printStackTrace();
					throw e;
				 } finally {
				    sqlMap.endTransaction();
				}
	}
	
	public List ListaCalcPresOtrosBanc(Bnchf53CalPrestOtroBanc bnchf53CalPrestOtroBanc) throws Exception{
			return sqlMap.queryForList("sqlCalPresOtrosBanc.listaPresOtrosBanc",bnchf53CalPrestOtroBanc);
	}
	
	public String sumaCuotaMens(Bnchf53CalPrestOtroBanc bnchf53CalPrestOtroBanc) throws Exception{    
        try {
        	 
        	String suma = (String)sqlMap.queryForObject("sqlCalPresOtrosBanc.sumaCuotaMens",bnchf53CalPrestOtroBanc);
            if(suma==null)
            	suma = "0";
             return suma;
        } catch (Exception e) {
            throw new Exception("sumaCuotaMens: " + e);
        }
    }
	
	
}
